package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.pojo.Order;
import com.pojo.Product;
import com.pojo.User;

import java.util.HashMap;
import java.util.List;
import java.util.Set;


@Controller
public class ordercontroller {
    @RequestMapping("/showOrder")
    public void findOrder(User user) {
        List<Order> orders = user.getOrders();
        List<String> addressList = user.getAddress();
        System.out.println("订单列表：");
        for (int i = 0; i < orders.size(); i++) {
            Order order = orders.get(i);
            String address = addressList.get(i);
            System.out.println("order = " + order);
            System.out.println("address = " + address);
        }
    }
        @RequestMapping("/orderInfo")
          public void getOrderInfo(Order order){
            String orderInfos = order.getOrderId();
            //获取商品信息
            HashMap<String, Product> orderInfo = order.getProductInfo();
            Set<String> keys = orderInfo.keySet();
            System.out.println("订单id"+orderInfos);
            System.out.println("订单商品信息：");
            for (String key : keys){
                Product product = orderInfo.get(key);
                String proId = product.getProId();
                String proName = product.getProName();
                System.out.println(key+"类~"+"商品id："+proId+"商品名称："+proName);
            }
        }

}
